package com.iplant.wms.serviceImpl.dao.asn;

import com.iplant.base.po.OutResult;
import com.iplant.base.po.enums.ExceptionTypes;
import com.iplant.base.utils.annotation.dao.DBBaseDAO;
import com.iplant.base.utils.general.StringUtils;
import com.iplant.base.utils.sql.BaseDAO;
import com.iplant.basic.service.po.bms.BMSEmployee;
import com.iplant.wms.service.po.asn.WMSArrivalVehicle;
import lombok.extern.slf4j.Slf4j;

import java.util.*;

/**
 * @author xiuto
 */
@Slf4j
@DBBaseDAO(WMSArrivalVehicle.class)
public class WMSArrivalVehicleDAO extends BaseDAO {


    private static WMSArrivalVehicleDAO Instance = null;

    private WMSArrivalVehicleDAO() {
        super("");
        this.Init();
    }

    public static WMSArrivalVehicleDAO getInstance() {
        if (Instance == null) {
            Instance = new WMSArrivalVehicleDAO();
        }
        return Instance;
    }





    /**
     * 删除集合
     */
    public void WMS_DeleteArrivalVehicleList(BMSEmployee wLoginUser, int wArrivalNoticeID,
                                             OutResult<Integer> wErrorCode) {
        try {
            if (wArrivalNoticeID<=0) {
                wErrorCode.set(ExceptionTypes.Parameter.getValue());
                return;
            }
            Map<String, Object> wDeleteParams = new HashMap<>();
            wDeleteParams.put("ArrivalNoticeID", wArrivalNoticeID);
            this.Delete(wDeleteParams, " and ID>0 ");

        } catch (Exception ex) {
            wErrorCode.set(ExceptionTypes.DBSQL.getValue());
            log.error("WMS_DeleteArrivalVehicleList", ex);
        }
    }

    public void WMS_DeleteArrivalVehicleList(BMSEmployee wLoginUser,List<Integer> wArrivalNoticeIDList,
                                             OutResult<Integer> wErrorCode) {
        try {
            if (wArrivalNoticeIDList == null || wArrivalNoticeIDList.size() == 0) {
                return;
            }
            this.Delete(StringUtils.Format("ArrivalNoticeID in ()",
                    StringUtils.Join(",", wArrivalNoticeIDList)), " and ID>0 ");

        } catch (Exception ex) {
            wErrorCode.set(ExceptionTypes.DBSQL.getValue());
            log.error("WMS_DeleteArrivalVehicleList", ex);
        }
    }




}
